package cn.cvs.service;

import cn.cvs.dao.MovieMapper;
import cn.cvs.pojo.Movie;
import cn.cvs.utils.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class MovieService {
    SqlSession session = MybatisUtil.createSqlSession();
    MovieMapper mapper = session.getMapper(MovieMapper.class);
    public List<Movie> list(int page, int end){
        int pagesize = (page-1)*end;
        List<Movie>list = mapper.list(pagesize,end);
        return list;
    }
    public int count(){
        int count = mapper.count();
        return count;
    }
    public int select(String name){
        int count = mapper.select(name);
        return count;
    }
    public int intmovie(Movie movie){
        int count = mapper.insertmovie(movie);
        if (count>0){
            session.commit();
        }else {
            session.rollback();
        }
        return count;
    }
}
